package com.ruoyi.classai.controller;

import com.ruoyi.classai.domain.EwcResourceDetails;
import com.ruoyi.classai.domain.dto.resource.EwcResourceDetailsAddDto;
import com.ruoyi.classai.domain.dto.resource.EwcResourceDetailsQueryDto;
import com.ruoyi.classai.domain.vo.resource.EwcResourceDetailsVo;
import com.ruoyi.classai.service.IEwcResourceDetailsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资源详情信息Controller
 *
 * @author lcj
 * @date 2025-03-16
 */
@RestController
@RequestMapping("/resourcedetails")
public class EwcResourceDetailsController extends BaseController {
    @Autowired
    private IEwcResourceDetailsService ewcResourceDetailsService;

    /**
     * 分页查询资源详情信息列表
     */
    @RequiresPermissions("classai:resourcedetails:list")
    @GetMapping("/list")
    public TableDataInfo list(EwcResourceDetailsQueryDto dto) {

        startPage();
        List<EwcResourceDetails> list = ewcResourceDetailsService.queryList(dto);
        return getDataTable(list);
    }

//    /**
//     * 导出资源详情信息列表
//     */
////    @RequiresPermissions("classai:resourcedetails:export")
//    @Log(title = "资源详情信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, EwcResourceDetails ewcResourceDetails) {
//        ewcResourceDetailsService.export(response, ewcResourceDetails);
//    }

    /**
     * 获取资源详情信息详细信息
     */
    @RequiresPermissions("classai:resourcedetails:query")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success("查询成功", ewcResourceDetailsService.getInfo(id));

    }

    /**
     * 新增资源详情信息
     */
    @RequiresPermissions("classai:resourcedetails:add")
    @Log(title = "资源详情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Validated EwcResourceDetailsAddDto dto) {
        ewcResourceDetailsService.add(dto);
        return AjaxResult.success("操作成功！");
    }

    /**
     * 修改资源详情信息
     */
    @RequiresPermissions("classai:resourcedetails:edit")
    @Log(title = "资源详情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody @Validated EwcResourceDetailsAddDto dto) {
        ewcResourceDetailsService.edit(dto);
        return AjaxResult.success("操作成功！");
    }

    /**
     * 删除资源详情信息
     */
    @RequiresPermissions("classai:resourcedetails:remove")
    @Log(title = "资源详情信息", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        ewcResourceDetailsService.remove(ids);
        return AjaxResult.success("操作成功！");
    }

    /**
     * 查询资源详情信息列表（不分页）
     */
    @RequiresPermissions("classai:resourcedetails:resourceDetailsList")
    @PostMapping("/resourceDetailsList")
    public AjaxResult resourceDetailsList(@RequestBody EwcResourceDetailsQueryDto dto) {

        List<EwcResourceDetailsVo> list = ewcResourceDetailsService.resourceDetailsList(dto);
        return AjaxResult.success("操作成功！", list);
    }

}
